﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ApiDoc
{
    /// <summary>
    /// String with markup.
    /// </summary>
    public class MarkupString
    {
        /// <summary>
        /// Create a MarkupString from <paramref name="s"/>.
        /// </summary>
        public MarkupString(string s, IMemberDocumentation member, ApiDocumentationManager manager)
        {
            m_original = s;
            m_member = member;
            m_manager = manager;
        }

        private string m_original;
        private IMemberDocumentation m_member;
        private ApiDocumentationManager m_manager;

        /// <summary>
        /// Returns the owner of this markup.
        /// </summary>
        /// <returns></returns>
        public IMemberDocumentation GetOwner()
        {
            return m_member;
        }

        /// <summary>
        /// Returns the manager of this markup.
        /// </summary>
        /// <returns></returns>
        public ApiDocumentationManager GetManager()
        {
            return m_manager;
        }

        /// <summary>
        /// Create a MarkupString from <paramref name="s"/>.
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static MarkupString Create(string s, IMemberDocumentation member, ApiDocumentationManager manager)
        {
            return new MarkupString(s, member, manager);
        }

        public override string ToString()
        {
            return m_original;
        }

        /// <summary>
        /// Allow implicit casting to strings to make it easy and natrual for people to do things like
        /// String.IsNullOrEmpty(myMarkupString).
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static implicit operator string(MarkupString s)
        {
            return s.ToString();
        }
    }
}
